<template>
	<view>
		<u-cell-group v-for="item in recordList" :key="item.id">
			<u-cell>

				<view slot="title" class="cell-content">
					<view class="title-line">
						<text class="paper-title">{{item.paperName}}</text>

					</view>
					<view class="info-line">
						<text class="subject-tag">{{item.subjectName}}</text>
						<text>对错：{{item.questionCorrect}}/{{item.questionCount}}</text>
						<text class="time">时间：{{formatTime(item.createTime)}}</text>
					</view>
				</view>

				<view slot="right-icon" class="action-button">
					<u-button size="mini" :plain="true">
						{{item.status === 1 ? '查看' : '去批改'}}
					</u-button>
				</view>

			</u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	import http from '../../http';
	export default {
		data() {
			return {
				recordList: [],
				recordpage: {
					pageIndex: 1,
					pageSize: 10
				}
			}
		},
		methods: {

			getrecord() {
				http({
					url: "/api/student/exampaper/answer/pageList",
					method: "post",
					data: this.recordpage
				}).then(res => {
					console.log(res);
					this.recordList = res.response.list
				})
			},

			// 格式化时间显示
			formatTime(timeString) {
				if (!timeString) return '';
				// 移除秒部分
				return timeString.substring(0, 16);
			},

		},
		onLoad() {
			this.getrecord()
		}
	}
</script>

<style lang="scss">
	.cell-content {
		width: 100%;
		padding: 8rpx 0;

		.title-line {
			display: flex;
			align-items: center;
			margin-bottom: 10rpx;

			.paper-title {
				// font-size: 32rpx;
				font-weight: bold;
				margin-right: 20rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				max-width: 400rpx;
			}

			.subject-tag {
				background-color: #f0f7ff;
				color: #2979ff;
				// font-size: 24rpx;
				padding: 4rpx 12rpx;
				border-radius: 8rpx;
			}
		}

		.info-line {
			display: flex;
			justify-content: space-between;
			// font-size: 26rpx;
			color: #666;

			.time {
				color: #999;
			}
		}
	}

	.action-button {
		margin-left: 20rpx;

		.u-button {
			width: 120rpx;
			height: 50rpx;
			line-height: 50rpx;
		}
	}
</style>